package com.chenjj.java.test.juc.tools;

import com.chenjj.java.juc.tools.cyclicbarrier.Tourist;
import org.junit.Test;

import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CyclicBarrierTester {

    @Test
    public void test1() throws InterruptedException {
        CyclicBarrier cyclicBarrier = new CyclicBarrier(3);

        Tourist tourist1 = new Tourist("zhangsan",cyclicBarrier);
        Tourist tourist2 = new Tourist("lisi",cyclicBarrier);
        Tourist tourist3 = new Tourist("wangwu",cyclicBarrier);

        ExecutorService executorService = Executors.newFixedThreadPool(10);

        executorService.execute(tourist1);
        executorService.execute(tourist2);
        executorService.execute(tourist3);

        Thread.sleep(60*1000);

    }
}
